<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="layout/layout.xhtml">
	<ui:define name="content">
		<f:view locale="#{LocalizationController.locale}">
			<h:form enctype="multipart/form-data">
				<a4j:poll id="poll" interval="2000" ajaxRendered="true"
					enabled="#{SessionManagerController.isPollerRunning}"
					reRender="fileUploadPanel,UploadFileBox,InputTextBox,MessageOkBox,MessageBox" />
				<a4j:poll id="buttonPoller" enabled="true" interval="2000"
					reRender="buttonPanel,sessionState, backButtonPanel, actionList" />
					
					
				<!-- TITOLO + STATO -->	
				<div class="row" style="margin-left: 10px;">
					<div class="span5">
						<h3 style="display: inline-block;"><h:outputText value="#{msgs.Session21Title}" /></h3>
						<div
							style="display: inline-block; float: right; height: 60px; line-height: 60px;">
							<strong style="margin-right: 10px;"><h:outputText value="#{msgs.Session3State}" /></strong> &nbsp;
							<a4j:outputPanel id="sessionState" styleClass="label label-info"
								style="text-transform:uppercase;">
								<h:outputText value="#{SessionManagerController.sessionState}" />
							</a4j:outputPanel>
						</div>
					</div>
				</div>


				<!-- INFO SESSIONE -->
				<div class="row" style="margin-left: 10px;">
					<div class="span5">
						<h5 class="headerUnderlined"><h:outputText value="#{msgs.Session22Details}" /></h5>

						<table class="table table-striped">
							<tr>
								<td><label class="control-label" for="output_test_plan"><h:outputText value="#{msgs.Session6TestPlan}" /></label></td>
								<td><h:outputText id="output_test_plan"
										value="#{SessionManagerController.viewCurrentSession.testPlan.name}" />
								</td>
							</tr>
							<tr>
								<td><label class="control-label" for="output_sut"><h:outputText value="#{msgs.Session5SUT}" /></label>
								</td>
								<td><h:outputText id="output_sut"
										value="#{SessionManagerController.viewCurrentSession.sut.name}" />
								</td>
							</tr>
						</table>
					</div>
					
					
					<!-- CONTROLS -->
					<div class="span4 offset3">

						<h5 class="headerUnderlined"><h:outputText value="#{msgs.Session24Controls}" /></h5>
						<div>
							<a4j:outputPanel id="buttonPanel">
								<a4j:commandButton value="#{msgs.Session241Run}" styleClass="btn btn-success"
									rendered="#{SessionManagerController.canBeExecuted}"
									action="#{SessionManagerController.execute}"
									reRender="actionList, fileUploadPanel,UploadFileBox,InputTextBox,MessageOkBox,MessageBox" />
								<a4j:commandButton value="#{msgs.Session241Run}" styleClass="btn disabled"
									rendered="#{!SessionManagerController.canBeExecuted}" />
								<a4j:commandButton value="#{msgs.Session242Suspend}" styleClass="btn btn-danger"
									rendered="#{SessionManagerController.canBeStopped}"
									style="margin-left: 10px;"
									action="#{SessionManagerController.suspend}" />
								<a4j:commandButton value="#{msgs.Session242Suspend}" styleClass="btn disabled"
									rendered="#{!SessionManagerController.canBeStopped}"
									style="margin-left: 10px;" />
								<a4j:commandButton value="#{msgs.Session243Resume}" styleClass="btn btn-primary"
									rendered="#{SessionManagerController.canBeRestarted}"
									style="margin-left: 10px;" />
								<a4j:commandButton value="#{msgs.Session243Resume}" styleClass="btn disabled"
									rendered="#{!SessionManagerController.canBeRestarted}"
									style="margin-left: 10px;" />
							</a4j:outputPanel>
							
						</div>
					</div>
				</div>
				<hr />

				<!-- ACTIONS -->
				<div class="row" style="margin-left: 10px;">
					<div class="span5">
						<h5 class="headerUnderlined"><h:outputText value="#{msgs.Session23Actions}" /></h5>
						<a4j:outputPanel>
							<t:dataTable id="actionList" var="action"
								styleClass="table table-striped"
								value="#{SessionManagerController.viewCurrentSession.testPlan.workflow.actions}"
								preserveDataModel="false">
								<h:column>
									<h:panelGroup
										rendered="#{action.id eq SessionManagerController.currentAction.id}">
										<i class="icon-chevron-sign-right green icon-2x"></i>
									</h:panelGroup>
								</h:column>
								<h:column>
									<h:outputText value="#{action.actionName}" />
								</h:column>

							</t:dataTable>
						</a4j:outputPanel>
					</div>

					<!-- FORM GUI REACTION -->
					<a4j:outputPanel id="fileUploadPanel">
						<a4j:outputPanel
							rendered="#{SessionManagerController.isSessionWaiting}"></a4j:outputPanel>
						<a4j:outputPanel id="UploadFileBox"
							rendered="#{SessionManagerController.showUploadFileBox}">
							<div class="span4 offset3">
								<!-- GUIMESSAGE -->
								<h6>
									<h:outputText value="#{SessionManagerController.guiMessage}" />
								</h6>
								<!-- FILE SELECTION -->
								<rich:fileUpload
									fileUploadListener="#{SessionManagerController.fileUploadListener}"
									id="upload"
									maxFilesQuantity="#{SessionManagerController.uploadsAvailable}"
									immediateUpload="true" allowFlash="false"
									acceptedTypes="pdf,png,jpg,txt,html,xml"
									noDuplicate="true" clearAllControlLabel="#{msgs.Session246DeleteAll}"
									clearControlLabel="#{msgs.Session247Delete}" doneLabel="#{msgs.Session248Done}">
									<a4j:support event="onuploadcomplete" />
									<a4j:support event="onclear" reRender="fileUploadPanel"
										actionListener="#{SessionManagerController.clearUploadedFile}" />
								</rich:fileUpload>
								<!-- SAVE BUTTON -->
								<a4j:commandButton value="#{msgs.Session249Save}"
									styleClass="btn btn-primary"
									style="margin-top:10px; float:right;"
									action="#{SessionManagerController.upload}"
									reRender="fileUploadPanel,sessionState" />
							</div>
						</a4j:outputPanel>

						<!-- INPUT TEXT BOX -->
						<a4j:outputPanel id="InputTextBox"
							rendered="#{SessionManagerController.showInputTextBox}">
							<div class="well span4 offset1">
								<h6>
									<h:outputText value="#{SessionManagerController.guiMessage}" />
								</h6>
								<div class="controls">
									<h:inputText id="inputMessage"
										value="#{SessionManagerController.inputTextMessage}" />
								</div>
								<a4j:commandButton styleClass="btn btn-primary" value="#{msgs.Session245Ok}"
									style="margin-top:10px;"
									action="#{SessionManagerController.upload}" />
							</div>
						</a4j:outputPanel>
						
						<!-- MESSAGE OK BOX -->
						<a4j:outputPanel id="MessageOkBox"
							rendered="#{SessionManagerController.showMessageOkBox}">
							<div class="well span4 offset1">
								<h6>
									<h:outputText value="#{SessionManagerController.guiMessage}" />
								</h6>
								<a4j:commandButton value="#{msgs.Session245Ok}" styleClass="btn btn-primary"
									style="margin-top:10px;"
									action="#{SessionManagerController.execute}" />
							</div>
						</a4j:outputPanel>
						
						<!-- MESSAGE BOX -->
						<a4j:outputPanel id="MessageBox"
							rendered="#{SessionManagerController.showMessageBox}">
							<div class="alert alert-info span4 offset3">
								<h:outputText value="#{SessionManagerController.guiMessage}" />
							</div>
						</a4j:outputPanel>
					</a4j:outputPanel>
				</div>

				<hr />


				<!-- CONSOLE -->
				<div class="row" style="margin-left: 10px;" >
					<h5 class="headerUnderlined"><h:outputText value="#{msgs.Session25Console}" /></h5>
				</div>
				<div class="row sessionConsole">
					<a4j:outputPanel id="consolePanel" ajaxRendered="true">
						<h:outputText value="#{SessionManagerController.logMessage}" escape="false" />
					</a4j:outputPanel>
				</div>


			</h:form>
		</f:view>
	</ui:define>
</ui:composition>
</html>